package com.xuxueli.applyModules.commont;
import lombok.AllArgsConstructor;

/**
 * 时间单位
 */
@AllArgsConstructor
public enum TimeUnitEnum {

    SECOND("ss", 1),
    MINUTER("mm", 60),
    HOUR("hh", 60 * 60),
    DAY("dd", 24 * 60 * 60);

    private String code;
    private Integer value;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public static Integer getValueByCode(String code) {
        TimeUnitEnum[] values = TimeUnitEnum.values();
        for (TimeUnitEnum timeUnitEnum : values) {
            if (timeUnitEnum.getCode().equals(code)) {
                return timeUnitEnum.getValue();
            }
        }
        return null;
    }
}
